livecodefandomcom-20200223-history
RevVideoGrabber
=Using the Revolution Video Grabber= Revolution includes an external library of commands that lets you capture video from a camera attached to your computer, using capabilities included in QuickTime. There is very little written on how to use it, so this is an attempt to gather all the information I can find about it into a single place. First I'll describe the basic process of video capture, then give a listing of all of the video grabber commands included with Revolution. Finally, I include some random notes that I have come across in which other Rev developers have described their experiences with the Video Grabber. Note: The Video Grabber library only exists for Mac OS and Windows systems. The Basic Process Since I work on Mac OS X, and therefore use QuickTime, I will describe what I did to make video capture work using QuickTime. I assume that Windows with QT installed will work the same, but I don't have the time or equipment to test it. This is the system configuration I was using when I created this tutorial (June 2008): *2.33 GHz Intel Core 2 Duo iMac *2 GB of RAM *Mac OS X v. 10.4.11 *Revolution 2.9.0-gm-1 (build 610) *QuickTime v. 7.4.5 I first tried out the Video Capture.rev stack that comes in the Sample Projects folder with your copy of Revolution. It didn't work completely right for me, so I combed through its handlers and was able to grok it enough to put together a working sample of my own. In order for the Video Grabber to work you must be careful to do the following, in order: Initialize video capture using the revInitializeVideoGrabber command. Optionally set the rectangle the capture window will use with the revSetVideoGrabberRect command. Choose, save and set the video grabber settings. Here is the handler I used: on mouseUp revVideoGrabDialog local vSettings --docs say the variable has to exist before referring to it revVideoGrabSettings "vSettings" set the videoSettings of this cd to vSettings revSetVideoGrabSettings "vSettings" end mouseUp A big key to making it all work right is to set the revVideoGrabIdle command at regular intervals so that you give QuickTime enough clock cycles to do its thing. Here's the handler I came up with that worked (be sure to put it in the message path of the buttons you use to start video capture.) global gMsgId on videoRefresh revVideoGrabIdle send "videoRefresh" to me in 10 milliseconds put the result into gMsgId end videoRefresh Now, whenever you preview or capture video to a file you have to make sure you call the above handler. Here's how to start video preview: revPreviewVideo videoRefresh To stop video preview just do: global gMsgId on mouseUp revStopPreviewingVideo cancel gMsgId -- so you don't keep trying to call revVideoGrabIdle end mouseUp Here's how to start recording video to a file: set the filetype to "TVODMooV" --make sure Mac OS knows what it is revRecordVideo to file videoRefresh Stopping recording is similar to stopping preview: global gMsgId on mouseUp revStopRecordingVideo cancel gMsgId end mouseUp The video should now be saved in the file you specified in step 8 above. The last thing you have to do is close the video grabber using the revCloseVideoGrabber command. So there you have it. It's not perfect, but it works. You can probably get it to work better by experimenting and tweaking. If you want to have a look at my video grabber test stack, download the stack from http://revolution.byu.edu/video/videoGrabberTest.rev or just get it in Revolution by entering in your message box: go to stack URL "http://revolution.byu.edu/video/videoGrabberTest.rev" A Compilation of All Video Grabber Entries from the Revolution Scripting Dictionary These are all quoted from the Revolution dictionary that's included with Revolution. I found it useful to get them all in one place and in a more or less logical order. Keep in mind that RunRev may choose to update them with new releases, so always refer to your copy of the Rev dictionary to make sure you have the latest information. * revInitializeVideoGrabber *revCloseVideoGrabber *revVideoGrabDialog *revVideoGrabSettings *revSetVideoGrabSettings *revPreviewVideo *revStopPreviewingVideo *revRecordVideo *revStopRecordingVideo *revVideoGrabIdle *revSetVideoGrabberRect *revVideoFrameImage Important! All of these commands are part of the Video library. To ensure that these commands work in a standalone application, you must include this custom library when you create your standalone. In the Inclusions section on the General screen of the Standalone Application Settings window, make sure that "Video Grabber" is selected from the list of script libraries.